using System;

namespace PSSymbolStore
{
    public class DeleteTransaction : Transaction
    {
        public DeleteTransaction()
        {
            TransactionType = TransactionType.Delete;
        }

        public DeleteTransaction(TransactionType transactionType)
            : base(transactionType)
        {
            TransactionType = TransactionType.Delete;
        }

        public DeleteTransaction(string transactionId, TransactionType transactionType)
            : base(transactionId, transactionType)
        {
            TransactionType = TransactionType.Delete;
        }

        private string _deletedTransactionId;

        public string DeletedTransactionId
        {
            get { return _deletedTransactionId; }
            set
            {
                if (_deletedTransactionId != value)
                {
                    _deletedTransactionId = value;
                    OnDeletedTransactionIdChanged(EventArgs.Empty);
                }
            }
        }

        public event EventHandler DeletedTransactionIdChanged;

        protected void OnDeletedTransactionIdChanged(EventArgs e)
        {
            if (DeletedTransactionIdChanged != null)
            {
                DeletedTransactionIdChanged(this, e);
            }
        }

        public override string ToString()
        {
            return String.Format("{0},del,{1}", TransactionId, DeletedTransactionId);
        }
    }
}
